<template>
  <div>
    <div class="content h310 mb10 ">
      <div
        class="s-tac s-d-flex s-ai-center s-jc-center h278"
        v-if="dataListShow"
      >
        <div>
          <img
            class="w190 h120"
            src="~@/assets/nodata.png"
            alt=""
          >
          <div
            style="color:#A8A8A8"
            class="fz14"
          >暂无数据</div>
        </div>
      </div>
      <ul
        class=""
        v-else
      >
        <li
          class="s-d-flex s-ai-center content-li pt5 pb5 h40 lh40 w100p"
          style="border-bottom:1px solid #EBEDF0"
          v-for="(item,index) in dataList"
          :key="index"
        >
          <div class="s-d-flex s-jc-space-between w100p">
            <div>
              <span>{{item.name}}</span>
            </div>
            <div
              class="s-pointer"
              @click="handleCreditStatus('success',item)"
            >
              申请加入
            </div>
          </div>

          <!-- <div class="pl15 eps-1 fz14">
            {{item.hospitalBaseName?item.hospitalBaseName:''}} {{item.time?item.time:''}} {{item.type | filter_alarm_type}}
          </div> -->
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import * as alarmRecordApi from "@/api/alarmRecord";
import * as hospitalApi from "@/api/hospital";
export default {
  data() {
    return {
      dataList: [],
      dataListShow:false
    };
  },
  created() {
    this.handleGetDataList();
  },
  methods: {
    //获取列表数据
    handleGetDataList() {
      const params = {
        pageIndex: 1,
        pageSize: 7,
        creditStatus: "wait",
      };
      hospitalApi.hospitalGetList(params).then((res) => {
        if (res && res.success) {
          this.dataList = res.data;
          this.total = res.total;
          if (res.data && res.data.length != 0) {
            this.dataListShow = false;
          } else {
            this.dataListShow = true;
          }
        }
      });
    },
    handleGoToNav() {
      this.$router.push({
        path: "/alarmInfo/alarmRecord",
      });
    },
    handleCreditStatus(type, item) {
      this.$confirm(
        `${type == "success" ? "是否同意认证" : "是否拒绝认证"}, 是否继续?`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          hospitalApi
            .hospitalBaseSave({
              id: item.id,
              creditStatus: type,
              adminMobile: item.adminMobile,
            })
            .then((res) => {
              if (res && res.success) {
                this.handleGetDataList();
                this.$message({
                  type: "success",
                  message: `${
                    type == "success" ? "同意认证成功" : "已拒绝认证"
                  }`,
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.flex-1 {
  flex: 1;
}
.content-li div {
  color: #909399;
}
</style>